package com.flame.core.protocol;

public class Result<T> {

    private String code;

    private String msg;

    private T data;

    public static <T> Result success() {
        Result<T> result = new Result<>();
        result.setCode("0");
        result.setMsg("success");
        return result;
    }

    public static <T> Result success(T data) {
        Result<T> result = new Result<>();
        result.setCode("0");
        result.setMsg("success");
        result.setData(data);
        return result;
    }

    public static <T> Result failure() {
        Result<T> result = new Result<>();
        result.setCode("-1");
        result.setMsg("failure");
        return result;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Result code(String code) {
        this.setCode(code);
        return this;
    }

    public Result msg(String msg) {
        this.setMsg(msg);
        return this;
    }

    public Result data(T data) {
        this.setData(data);
        return this;
    }
}
